saveToString

abstract suspend fun saveToString(scene: DesignBlock, allowedResourceSchemes: List<String> = listOf("blob", "bundle", "file", "http", "https")): String

Serializes the current scene into a string. Selection is discarded. If a resource uri has a scheme that is not in allowedResourceSchemes, an exception will be thrown.

Return

a serialized scene string.

Parameters

scene

the scene to serialize.

allowedResourceSchemes

the list of allowed resource schemes in the scene.


abstract suspend fun saveToString(scene: DesignBlock, options: SaveToStringOptions): String

Serializes the current scene into a string with optional compression. Selection is discarded. If a resource uri has a scheme that is not in options.allowedResourceSchemes, an exception will be thrown.

While a font loads, its text is laid out with another font. When the text's size follows its content, a scene saved before the font arrives can differ from one saved after it. To compare two saved scenes, first call engine.block.forceLoadResources(listOf(scene)). It throws when a resource fails to load, and you can still save the scene then.

Return

a serialized scene string.

Parameters

scene

the scene to serialize.

options

save options containing:

  • allowedResourceSchemes: The list of allowed resource schemes in the scene. Defaults to "blob", "bundle", "file", "http", "https". Add "data" to keep data: URIs.

  • compression: Optional compression settings containing:

    • format: Compression format (NONE or ZSTD). Defaults to NONE.

    • level: Compression level (FASTEST, DEFAULT, or BEST). Defaults to DEFAULT.